Skip to content

Expose keyring trace in results #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 20, 2020
Merged

Expose keyring trace in results #224

merged 7 commits into from
Mar 20, 2020

Conversation

mattsb42-aws
Copy link
Member

Issue #, if available:
resolves: #223

Description of changes:

After discussing #223 with @WesleyRosenblum and @acioc, we agreed that going with option 2 made the most sense and did not introduce notable risk of breaking customers. The fact that none of the tests (aside from an over-mocked unit test) needed to be changed after I changed the return values supports this conclusion.

There are two main changes introduced here, both with the aim of making the keyring trace accessible to callers:

  1. The streaming classes now set a keyring_trace attribute as soon as they have the encryption/decryption materials.
  2. The one-step APIs now return the new CryptoResult rather than a tuple. CryptoResult gives us the flexibility to add more output values in the future while also allowing unpacking and positional referencing just like the previous output (a 2-member tuple) did.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Check any applicable:

  • Were any files moved? Moving files changes their URL, which breaks all hyperlinks to the files.

@mattsb42-aws mattsb42-aws requested review from acioc, WesleyRosenblum and a team March 18, 2020 19:20
Copy link
Contributor

@WesleyRosenblum WesleyRosenblum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conceptually I'm good with it, others should review the syntax though



@attr.s
class CryptoResult(object):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any value in calling this AwsCryptoResult to match Java?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO no, but I'm willing to be convinced otherwise.

My reasoning is that aside from the name/branding and the AWS KMS keyring, nothing about the ESDK is AWS-specific. As such, I've tried to avoid including "AWS" in the names of things except where they specifically relate to AWS (ex: keyrings.aws_kms).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm fine with keeping it. As you know we changed the name more out of necessity than because it was a better name.

@mattsb42-aws mattsb42-aws added this to the keyrings milestone Mar 18, 2020
Copy link

@acioc acioc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, minor comments below. No changes blocking, but :shipit: based on responses/ any other commits.

@@ -2,6 +2,24 @@
Changelog
*********

1.5.0 -- 2020-xx-xx
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this will be updated once it's shipped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. That's out standard placeholder for "this release hasn't shipped yet".

CHANGELOG.rst Outdated
Major Features
--------------

* Add Keyrings
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth noting what Keyrings/ Keyring changes

CHANGELOG.rst Outdated
For backwards compatibility,
:class:`CryptoResult` also unpacks like a 2-member tuple.
This allows for backwards compatibility with the previous outputs
so this change should not break any existing consumers.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we note where it could break?

Comment on lines +16 to +17
from aws_encryption_sdk.identifiers import Algorithm, ContentType, KeyringTraceFlag, ObjectType, SerializationVersion
from aws_encryption_sdk.structures import (
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we format these differently?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -30 to -31
self.mock_stream_encryptor_instance.read.return_value = sentinel.ciphertext
self.mock_stream_encryptor_instance.header = sentinel.header
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume these values used to be the same before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the "over-mocked" test I mentioned in the description. TLDR is that CryptoResult enforces input types and mock sentinels are not those types.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, if you were asking if these values were similarly consistent, yes; mock sentinels are "an arbitrary named objects that are always the same within an execution".

Copy link

@acioc acioc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@mattsb42-aws mattsb42-aws merged commit 1bd5fa6 into aws:keyring Mar 20, 2020
@mattsb42-aws mattsb42-aws deleted the trace branch March 20, 2020 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants